package cn.edu.cug.cs.gtl.plugins.redner4oi.nodes;

import cn.edu.cug.cs.gtl.apis.render.nodes.Group;
import cn.edu.cug.cs.gtl.apis.render.nodes.Node;
import com.openinventor.inventor.nodes.SoGroup;
import com.openinventor.inventor.nodes.SoNode;

public class GroupImpl extends NodeImpl implements Group {

    public GroupImpl() {
        super();
        this.nativeObject = new SoGroup();
    }

    public GroupImpl(SoGroup group) {
        super();
        this.nativeObject = group;
    }

    @Override
    public boolean attach(Object nativeObject) {
        if(nativeObject instanceof SoGroup)
            this.nativeObject = (SoGroup)nativeObject;
        else
            return false;

        return true;
    }

    @Override
    public void addChild(Node child) {
        if(child==null)
            return;
        if(child.getNativeObject() instanceof SoNode)
            ((SoGroup)this.nativeObject).addChild((SoNode)child.getNativeObject());
    }
}
